#region [file: UsuarioDAL.cs, author: Lucas Bittencourt]
// File:    UsuarioDAL.cs
// Author:  Lucas Bittencourt
// Created: terça-feira, 13 de setembro de 2011 23:34:04
// Purpose: Defines dao implementation class for class Usuario
#endregion

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using NHibernate.Criterion;
using DA_OOMModel;
using DA_OOMModelIDAL;

namespace DA_OOMNHibernateDAL
{
   /// <summary>
   /// Class that implements methods of IUsuarioDAL interface
   /// </summary>
    public partial class UsuarioDAL : NHibernateDALBase, IUsuarioDAL 
   {
      #region CRUD methods
      /// <summary>
      /// Get all instances of Usuario
      /// </summary>     
      public List<Usuario> GetUsuarioList()
      {
         return ConvertToGenericList(base.LoadAll(typeof(Usuario)));
      }
      
      /// <summary>
      /// Get the instances of Usuario from index firstResult to index maxResult
      /// </summary>
      public List<Usuario> GetUsuarioList(int firstResult, int maxResult)
      {
         return ConvertToGenericList(base.LoadAll(typeof(Usuario), firstResult, maxResult));
      }

      /// <summary>
      /// Load the instance of Usuario according its primary key instance.
      /// </summary>
      public Usuario Load(UsuarioPK usuarioPK)
      {
         IList cs = new ArrayList();
         string[] paramNames = new string[] { "UsrIdUsuario" };
         object[] values = new object[] { usuarioPK.UsrIdUsuario };
         for (int i = 0; i < paramNames.Length; i++)
             cs.Add(Expression.Eq(paramNames[i], values[i]));

         IList list = base.FindByCriterions(typeof(Usuario), cs);
         return (((list != null) && (list.Count > 0)) ? (Usuario)list[0] : null);
      }

      /// <summary>
      /// Query the instances of Usuario according its example instance.
      /// </summary>
      public List<Usuario> QueryByExample(Usuario usuario)
      {
         return ConvertToGenericList(base.QueryByExample(typeof(Usuario), usuario));
      }

      /// <summary>
      /// Query the instances of Usuario according its example instance from index firstResult to index maxResult
      /// </summary>
      public List<Usuario> QueryByExample(Usuario usuario, int firstResult, int maxResult)
      {
         return ConvertToGenericList(base.QueryByExample(typeof(Usuario), usuario, firstResult, maxResult));
      }
      
      /// <summary>
      /// Insert the instances of Usuario
      /// </summary>
      public void Insert(Usuario usuarioObject)
      {
         base.Save(usuarioObject);
      }
      
      /// <summary>
      /// Update the instances of Usuario
      /// </summary>
      public void Update(Usuario usuarioObject)
      {
         base.Update(usuarioObject);
      }
      
      /// <summary>
      /// Delete the instances of Usuario
      /// </summary>
      public void Delete(Usuario usuarioObject)
      {
         base.Delete(usuarioObject);
      }
      #endregion
      
   
      /// <summary>
      /// Find the instances of Usuario according to its attribute usrTpUsuario
      /// </summary>
      public List<Usuario> FindByUsrTpUsuario(TipoUsuario usrTpUsuario) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("UsrTpUsuario", usrTpUsuario));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs));
      }
      
      /// <summary>
      /// Find the instances of Usuario according to its attribute usrTpUsuario, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<Usuario> FindByUsrTpUsuario(TipoUsuario usrTpUsuario, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("UsrTpUsuario", usrTpUsuario));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of Usuario according to its attribute usrDsNickname
      /// </summary>
      public List<Usuario> FindByUsrDsNickname(string usrDsNickname) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("UsrDsNickname", usrDsNickname));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs));
      }
      
      /// <summary>
      /// Find the instances of Usuario according to its attribute usrDsNickname, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<Usuario> FindByUsrDsNickname(string usrDsNickname, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("UsrDsNickname", usrDsNickname));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of Usuario according to its attribute usrDsEmail
      /// </summary>
      public List<Usuario> FindByUsrDsEmail(string usrDsEmail) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("UsrDsEmail", usrDsEmail));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs));
      }
      
      /// <summary>
      /// Find the instances of Usuario according to its attribute usrDsEmail, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<Usuario> FindByUsrDsEmail(string usrDsEmail, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("UsrDsEmail", usrDsEmail));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of Usuario according to its attribute usrDsSenha
      /// </summary>
      public List<Usuario> FindByUsrDsSenha(string usrDsSenha) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("UsrDsSenha", usrDsSenha));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs));
      }
      
      /// <summary>
      /// Find the instances of Usuario according to its attribute usrDsSenha, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<Usuario> FindByUsrDsSenha(string usrDsSenha, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("UsrDsSenha", usrDsSenha));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of Usuario according to its attribute usrDsNome
      /// </summary>
      public List<Usuario> FindByUsrDsNome(string usrDsNome) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("UsrDsNome", usrDsNome));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs));
      }
      
      /// <summary>
      /// Find the instances of Usuario according to its attribute usrDsNome, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<Usuario> FindByUsrDsNome(string usrDsNome, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("UsrDsNome", usrDsNome));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs, firstResult, maxResult));
      }
      
      
      /// <summary>
      /// Find the instances of Usuario according to its attribute usrDsSobrenome
      /// </summary>
      public List<Usuario> FindByUsrDsSobrenome(string usrDsSobrenome) 
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("UsrDsSobrenome", usrDsSobrenome));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs));
      }
      
      /// <summary>
      /// Find the instances of Usuario according to its attribute usrDsSobrenome, 
      /// and the result is from index firstResult to  index maxResult
      /// </summary>
      public List<Usuario> FindByUsrDsSobrenome(string usrDsSobrenome, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("UsrDsSobrenome", usrDsSobrenome));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs, firstResult, maxResult));
      }
      /// <summary>
      /// Find <Code>Usuario</Code> instances by Pessoa
      /// </summary>
      /// <param name="pessoa"/>
      /// <returns>Usuario instance list</returns>
      public List<Usuario> FindByPessoa(Pessoa pessoa)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("Pessoa", pessoa));
         return ConvertToGenericList(base.FindByCriterions(typeof(Pessoa), cs));
      }
      
      
      /// <summary>
      /// Find <Code>Usuario</Code> instances  instances in range firstResult, maxResult by Pessoa
      /// </summary>
      /// <param name="pessoa"/>
      /// <param name="firstResult">first result to return</param>
      /// <param name="maxResult">max result to return</param>
      /// <returns>Usuario instance list</returns>
      public List<Usuario> FindByPessoa(Pessoa pessoa, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("Pessoa", pessoa));
         return ConvertToGenericList(base.FindByCriterions(typeof(Pessoa), cs, firstResult, maxResult));}
      /// <summary>
      /// Find <Code>Usuario</Code> instances by Cliente
      /// </summary>
      /// <param name="cliente"/>
      /// <returns>Usuario instance list</returns>
      public List<Usuario> FindByCliente(Cliente cliente)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("Cliente", cliente));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs));
      }
      
      /// <summary>
      /// Find <Code>Usuario</Code> instances  instances in range firstResult, maxResult by Cliente
      /// </summary>
      /// <param name="cliente"/>
      /// <param name="firstResult">first result to return</param>
      /// <param name="maxResult">max result to return</param>
      /// <returns>Usuario instance list</returns>
      public List<Usuario> FindByCliente(Cliente cliente, int firstResult, int maxResult)
      {
         IList cs = new ArrayList();
         cs.Add(Expression.Eq("Cliente", cliente));
         return ConvertToGenericList(base.FindByCriterions(typeof(Usuario), cs, firstResult, maxResult));
      }

      /// <summary>
      /// Convert the IList to the generic List instance.
      /// </summary>
      private List<Usuario> ConvertToGenericList(IList usuarios)
      {
         List<Usuario> usuarioList = new List<Usuario>();
         foreach (Usuario usuario in usuarios)
         {
             usuarioList.Add(usuario);
         }
         return usuarioList;
      }      
   }
}